<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>将 html 元素中文本内容用对应的 JavaScript 变量替换</title>
</head>
<body>
<div id="change" class="change">
    <h1>{{ i + 456 }}</h1>
    <h1>{{ info.toUpperCase() }}</h1>
</div>

<script>
    let info = "Hello, World!";
    let i = 123;

    let element = document.querySelector("#change > h1");
    // console.log(element);

    let text = element.innerText;
    // console.log(text);

    /*
    // 最标准的写法
    let replace = text.replaceAll("{", '').replaceAll("}", '').trim();
    console.log(replace);

    element.innerText = eval(replace)
    */

    element.innerText = eval(text)


</script>
</body>
</html>